import { Context, Session } from 'koishi'
import keyWordList from "./keyWordList";
const initKeyWord = (messageData: any, ctx: Context, session: Session) => {

    let content = messageData.message.content;

    // 去除两端空格
    content = content.trim();

    
    keyWordList.map((keywordItem) => {
        const reg = keywordItem.reg;
        const hasAction = reg.test(content);
        if (hasAction) {
            // 执行指令
            const fn = keywordItem.fn;
            fn(messageData, ctx, session)
        }
    })
}

export default initKeyWord